//
//  RCCheckInShopList.m
//  RocketProject
//
//  Created by chen jiedan on 13-9-24.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCCheckInShopList.h"
#import "KFObjectExtension.h"


//@implementation RCCheckInItemDataModel
//
//@synthesize merchant_name = _merchant_name;
//@synthesize merchant_id   = _merchant_id;
//@synthesize keywords = _keywords;
//@synthesize price   = _price;
//@synthesize distance = _distance;
//@synthesize picUrl  = _picUrl;
//@synthesize score    = _score;
//
//- (void) dealloc
//{
//    KF_RELEASE_SAFELY(_merchant_name);
//    KF_RELEASE_SAFELY(_merchant_id);
//    KF_RELEASE_SAFELY(_keywords)
//    KF_RELEASE_SAFELY(_price);
//    KF_RELEASE_SAFELY(_distance);
//    KF_RELEASE_SAFELY(_picUrl);
//    KF_RELEASE_SAFELY(_score);
//    [super dealloc];
//}
//
//@end


@implementation RCCheckInShopList


// 将JSON数据解析为数据模型
+(id) parseDataFromJSON:(NSDictionary*)data
{
    // 输入参数判断
    if ( nil == data )
        return nil;
    NSMutableArray *listItems = [[NSMutableArray alloc] init];

    RCCheckInShopList *retObject = [[[RCCheckInShopList alloc] init] autorelease];
    NSDictionary *dataDic = [data dictionaryValueForKey:@"data" defaultValue:nil];
    retObject.pn     = [dataDic intValueForKey:@"pn" defaultValue:0];
    retObject.rn     = [dataDic intValueForKey:@"rn" defaultValue:0];
    retObject.total  = [dataDic intValueForKey:@"total" defaultValue:0];
    
    NSArray *dataItems = [dataDic arrayValueForKey:@"list" defaultValue:nil];
    if (nil == dataItems) {
        dataItems = [dataDic arrayValueForKey:@"items" defaultValue:nil];
    }
    for (NSDictionary *dic in dataItems) {
        RCMerchant *item = [[RCMerchant alloc] initWithDic:dic];
//        item.merchantDistance = [dic stringValueForKey:@"distance" defaultValue:@"" operation:NSStringOperationTypeNone];
//        item.merchantTagsString = [dic stringValueForKey:@"keywords" defaultValue:@"" operation:NSStringOperationTypeNone];
//        item.merchantID = [dic stringValueForKey:@"merchant_id" defaultValue:@"" operation:NSStringOperationTypeNone];
//        item.merchantName = [dic stringValueForKey:@"merchant_name" defaultValue:@"" operation:NSStringOperationTypeNone];
//        item.merchantImageUrl = [dic stringValueForKey:@"picurl" defaultValue:@"" operation:NSStringOperationTypeNone];
//        item.merchantScore = [dic intValueForKey:@"score" defaultValue:0];
//        item.merchantPrice = [dic stringValueForKey:@"price" defaultValue:@"" operation:NSStringOperationTypeNone];
        [listItems addObject:item];
        [item release];
    }
    retObject.listItems = listItems;
    [listItems release];
    return retObject;
}


@end
